﻿using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Business
{
    public partial class Employee
    {
        public static void GetEmployeeByJobForCombo(ref List<ComboItem> list, string Job, bool isAllOptions = false)
        {
            DataClassesDataContext context = null;
            try
            {
                context = new DataClassesDataContext(Common.Global.GetConnectionInfo().ConnectionStringSQL);
                var query = context.Employees.Where(p=>p.JobTitle.Equals(Job.Trim()));
                foreach (var item in query)
                {
                    ComboItem add = new ComboItem(item.EmployeeCode, item.EmployeeName);
                    list.Add(add);
                }
                if (isAllOptions)
                    list.Insert(0, new ComboItem("000000", "Tất cả"));
            }
            catch
            {
                list = null;
                return;
            }
            finally
            {
                context = null;
            }
        }
    }

    public class EmployeeJob
    {
        public static string CS = "CS";
    }

    public class SimpleEmployee
    {
        public string EmployeeCode { get; set; }
        public string EmployeeName { get; set; }
    }
}
